package com.longge;

public class SmallestRangeI {
    public int smallestRangeI(int[] nums, int k) {

        int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
        for (int num : nums) {
            max = Math.max(max, num);
            min = Math.min(min, num);
        }
        if (max-min>2*k){
           return max-min-Math.multiplyExact(2,k);
        }
        return 0;
    }

}
